package com.brooks.demo;

/**
 * 单例模式 加锁
 * 锁粒度太粗
 * @Author: mihutu
 * @Date: 2020/10/11 21:47
 */

public class DemoSingleton3 {
    private static DemoSingleton3 singleton ;

    private DemoSingleton3() {

    }

    public static synchronized DemoSingleton3 getInstance() {
        if (singleton == null){
            singleton = new DemoSingleton3();
        }
        return singleton;
    }
}
